<?
	$title="User Role Management";
	require("required/dbconnect.php");
	require_once("required/function.php");
	require("required/header.php");
	checkAccess("allow_user_management",1);
	
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?	
		
	if(!empty($_GET['action']))
	{
		
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data inserted</div>";
				break;
			case 2:
				$msg="<div class='dw_success'>Data Deleted</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;	
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}else{
		$msg="";
	}
	
	
	
?>
<script>
	function frmvalidate(addfrm)
	{
		if(document.addfrm.role_name.value=="")
		{
			alert("Please insert role name");
			document.addfrm.role_name.focus();
			return false;
		}
		return true;
	}
	
	
	
</script>
<table width="100%">

    <td valign="top" align="left">
       <table width="100%" align="center">
       		<tr>
            	<td class="title"><?= $title ?></td>
            </tr>
            <tr>
            	<td><div id="divMsg"><?= $msg ?></div></td>
            </tr>
            <tr>
            	<td>
                	<table width="90%" class="solidborder" >
          				<Tr class="table_header">
                        	<td width="30">No.</td>
                        	<td width="350">Role Name</td>
                        	<td width="146" >Action</td>
                   	  	</Tr>
						<?
                            $get_data=mysql_query("select * from os_user_role order by role_name asc")or die;
                            
                            if(mysql_num_rows($get_data)==0)
                            {		
                        ?>
                        <tr>
                            <Td colspan="8" align="center"> No record found</Td>
                        </tr>
                        <? 
                            }
                            else
                            { 
                                $no=1;
                                
                                
                                
                                while($a=mysql_fetch_array($get_data,MYSQL_ASSOC))
                                {
                                    if($no%2==0)
                                    {
                                        $class1="table_item_even";
                                        $class2="table_item_odd";
                                    }
                                    else
                                    {
                                        $class1="table_item_odd";
                                        $class2="table_item_even";
                                    }
                        ?>
                            <tr height="20" valign="top" class="<?= $class1 ?>" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='<?= $class1 ?>'">
                            	<td><?= $no ?></td>
                                <td align="left"><?= $a['role_name'] ?></td>
                                
                                <td align="center">
                                	
                                <a href="user_role_edit.php?id=<?= $a['id'] ?>"><img src="images/icons/edit.gif" border="0"></a>

                                    <a href="user_role_delete.php?id=<?= $a['id'] ?>">
                                        <img src="images/icons/delete.gif" border="0">
                                    </a>
                                    
                                    
                                    
                                </td>
                            </tr>
                            <? 
									$no++;
									}
								}
							
							 ?>
                        
                        
                    </table>
                  <br>
                    
                  <input type="button" value="Add" onclick="window.open('user_role_add.php','_self')" />
                
              </td>
            </tr>
       </table>
       
    </td>
</table>					
<?
	require("required/footer.php");
?>               
        